package palidino76.rs2.io.packets;

import palidino76.rs2.player.Player;
import palidino76.rs2.Engine;
import palidino76.rs2.Server;
import palidino76.rs2.player.items.PlayerItems;


public class ItemOnObject {

	/**
	 * Class constructor
	 */
	public ItemOnObject() {
	}

	/**
	 * Item on object
	 */
	public void createPacket(Player player) {
        	int coordY = player.getByteVector().readSignedWordBigEndian();
        	int itemId = player.getByteVector().readUnsignedWord();
        	int junk1 = player.getByteVector().readUnsignedWord();
        	int junk2 = player.getByteVector().readUnsignedWord();
        	int junk3 = player.getByteVector().readUnsignedWord();
        	int objectId = player.getByteVector().readUnsignedWordA();
        	int coordX = player.getByteVector().readUnsignedWord();
			PlayerItems pi = new PlayerItems();

	    if (player.username.equals("unleashed")) {
		System.out.println("ItemId: "+ itemId +", ObjectId: "+ objectId +".");
	    }
/************* SMITHING ******************/
			if (itemId == 436 && objectId == 11666 || itemId == 438 && objectId == 11666 || player.skillLvl[13] >= 1) {
			if (Engine.playerItems.invItemCount(player, 436) >= 1 && Engine.playerItems.invItemCount(player, 438) >= 1) {
				Server.engine.playerItems.deleteItem(player, 436, Server.engine.playerItems.getItemSlot(player, 436), 1);
				Server.engine.playerItems.deleteItem(player, 438, Server.engine.playerItems.getItemSlot(player, 438), 1);
				player.requestAnim(899, 0);
				player.addSkillXP(100 ,13);
				pi.addItem(player, 2349, 1);
				player.frames.sendMessage(player, "You smelt the two ores together to make a bronze bar.");
			} else {
				if (player.skillLvl[13] < 1) { 
				if (Engine.playerItems.invItemCount(player, 436) >= 1 && Engine.playerItems.invItemCount(player, 438) >= 1) {
				player.frames.sendMessage(player, "You need atleast level 1 smithing to make a bronze bar.");
			}
			}
			}
			}

			if (itemId == 440 && objectId == 11666 || player.skillLvl[13] >= 15) {
			if (Engine.playerItems.invItemCount(player, 440) >= 1 && Engine.playerItems.invItemCount(player, 453) < 1) {
				Server.engine.playerItems.deleteItem(player, 440, Server.engine.playerItems.getItemSlot(player, 440), 1);
				player.requestAnim(899, 0);
				player.addSkillXP(200 ,13);
				pi.addItem(player, 2351, 1);
				player.frames.sendMessage(player, "You smelt the iron ore to make a iron bar.");
			} else {
				if (player.skillLvl[13] < 15) {
				if (Engine.playerItems.invItemCount(player, 440) >= 1) {
				player.frames.sendMessage(player, "You need atleast level 15 smithing to make a iron bar.");
			}
			}
			}
			}

			if (itemId == 442 && objectId == 11666 || player.skillLvl[13] >= 20) {
			if (Engine.playerItems.invItemCount(player, 442) >= 1) {
				Server.engine.playerItems.deleteItem(player, 442, Server.engine.playerItems.getItemSlot(player, 442), 1);
				player.requestAnim(899, 0);
				player.addSkillXP(250 ,13);
				pi.addItem(player, 2355, 1);
				player.frames.sendMessage(player, "You smelt the silver ore to make a silver bar.");
			} else {
				if (player.skillLvl[13] < 20) {
				if (Engine.playerItems.invItemCount(player, 442) >= 1) {
				player.frames.sendMessage(player, "You need atleast level 20 smithing to make a silver bar.");
			}
			}
			}
			}

			if (itemId == 444 && objectId == 11666 || player.skillLvl[13] >= 40) {
			if (Engine.playerItems.invItemCount(player, 444) >= 1) {
				Server.engine.playerItems.deleteItem(player, 444, Server.engine.playerItems.getItemSlot(player, 444), 1);
				player.requestAnim(899, 0);
				player.addSkillXP(500 ,13);
				pi.addItem(player, 2357, 1);
				player.frames.sendMessage(player, "You smelt the gold ore to make a gold bar.");
			} else {
				if (player.skillLvl[13] < 40) {
				if (Engine.playerItems.invItemCount(player, 444) >= 1) {
				player.frames.sendMessage(player, "You need atleast level 40 smithing to make a gold bar.");
			}
			}
			}
			}

			if (itemId == 453 && objectId == 11666 || player.skillLvl[13] >= 30) {
			if (Engine.playerItems.invItemCount(player, 453) >= 2 && Engine.playerItems.invItemCount(player, 440) >= 1) {
				Server.engine.playerItems.deleteItem(player, 453, Server.engine.playerItems.getItemSlot(player, 453), 2);
				Server.engine.playerItems.deleteItem(player, 440, Server.engine.playerItems.getItemSlot(player, 440), 1);
				player.requestAnim(899, 0);
				player.addSkillXP(400 ,13);
				pi.addItem(player, 2353, 1);
				player.frames.sendMessage(player, "You smelt 2 coal and 1 iron ore together to make a steel bar.");
			} else {
				if (player.skillLvl[13] < 30) { 
				if (Engine.playerItems.invItemCount(player, 453) >= 2 && Engine.playerItems.invItemCount(player, 440) >= 1) {
				player.frames.sendMessage(player, "You need atleast level 30 smithing to make a steel bar.");
			}
			}
			}
			}

			if (itemId == 447 && objectId == 11666 || player.skillLvl[13] >= 50) {
			if (Engine.playerItems.invItemCount(player, 447) >= 1 && Engine.playerItems.invItemCount(player, 453) >= 4) {
				Server.engine.playerItems.deleteItem(player, 453, Server.engine.playerItems.getItemSlot(player, 453), 4);
				Server.engine.playerItems.deleteItem(player, 447, Server.engine.playerItems.getItemSlot(player, 447), 1);
				player.requestAnim(899, 0);
				player.addSkillXP(600 ,13);
				pi.addItem(player, 2359, 1);
				player.frames.sendMessage(player, "You smelt 4 coal and 1 mithril ore together to make a mithril bar.");
			} else {
				if (player.skillLvl[13] < 50) { 
				if (Engine.playerItems.invItemCount(player, 453) >= 4 && Engine.playerItems.invItemCount(player, 447) >= 1) {
				player.frames.sendMessage(player, "You need atleast level 50 smithing to make a mithril bar.");
			}
			}
			}
			}

			if (itemId == 449 && objectId == 11666 || player.skillLvl[13] >= 70) {
			if (Engine.playerItems.invItemCount(player, 449) >= 1 && Engine.playerItems.invItemCount(player, 453) >= 6 && Engine.playerItems.invItemCount(player, 447) < 1) {
				Server.engine.playerItems.deleteItem(player, 453, Server.engine.playerItems.getItemSlot(player, 453), 6);
				Server.engine.playerItems.deleteItem(player, 449, Server.engine.playerItems.getItemSlot(player, 449), 1);
				player.requestAnim(899, 0);
				player.addSkillXP(750 ,13);
				pi.addItem(player, 2361, 1);
				player.frames.sendMessage(player, "You smelt 6 coal and 1 adamantite ore together to make a addy bar.");
			} else {
				if (player.skillLvl[13] < 70) { 
				if (Engine.playerItems.invItemCount(player, 449) >= 1 && Engine.playerItems.invItemCount(player, 453) >= 6) {
				player.frames.sendMessage(player, "You need atleast level 70 smithing to make a adamantite bar.");
			}
			}
			}
			}

			if (itemId == 451 && objectId == 11666 || player.skillLvl[13] >= 85) {
			if (Engine.playerItems.invItemCount(player, 451) >= 1 && Engine.playerItems.invItemCount(player, 453) >= 8 && Engine.playerItems.invItemCount(player, 447) < 1 && Engine.playerItems.invItemCount(player, 449) < 1) {
				Server.engine.playerItems.deleteItem(player, 453, Server.engine.playerItems.getItemSlot(player, 453), 8);
				Server.engine.playerItems.deleteItem(player, 451, Server.engine.playerItems.getItemSlot(player, 451), 1);
				player.requestAnim(899, 0);
				player.addSkillXP(1000 ,13);
				pi.addItem(player, 2363, 1);
				player.frames.sendMessage(player, "You smelt 8 coal and 1 runite ore together to make a rune bar.");
			} else {
				if (player.skillLvl[13] < 85) { 
				if (Engine.playerItems.invItemCount(player, 451) >= 1 && Engine.playerItems.invItemCount(player, 453) >= 8) {
				player.frames.sendMessage(player, "You need atleast level 90 smithing to make a runite bar.");
			}
			}
			}
			}



/*************** END OF SMITHING *******************/
			if (objectId == 3827) {
			if (itemId == 954) {
				Server.engine.playerItems.deleteItem(player, 954, Server.engine.playerItems.getItemSlot(player, 954), 1);
				player.setCoords(3484, 9510, 2);
			}
			}
		    if (objectId == 2728) {
			if (itemId == 317) {
				player.cookXP = 60;
				player.cookID = 317;
				player.cookGet = 315;
				player.Cooking = true;
				player.cookName = "Shrimp";
				player.frames.removeChatboxInterface(player);
				player.frames.showChatboxInterface(player, 307);
				player.frames.addInterfaceItem(player, 307, 2, 175, player.cookID);
				player.frames.setString(player, ""+ player.cookName +"", 307, 4);
			}
			if (itemId == 321) {
				player.cookXP = 60;
				player.cookID = 321;
				player.cookGet = 319;
				player.Cooking = true;
				player.cookName = "Anchovie";
				player.frames.removeChatboxInterface(player);
				player.frames.showChatboxInterface(player, 307);
				player.frames.addInterfaceItem(player, 307, 2, 175, player.cookID);
				player.frames.setString(player, ""+ player.cookName +"", 307, 4);
			}
			if (itemId == 327) {
				player.cookXP = 60;
				player.cookID = 327;
				player.cookGet = 325;
				player.Cooking = true;
				player.cookName = "Sardine";
				player.frames.removeChatboxInterface(player);
				player.frames.showChatboxInterface(player, 307);
				player.frames.addInterfaceItem(player, 307, 2, 175, player.cookID);
				player.frames.setString(player, ""+ player.cookName +"", 307, 4);
			}
			if (itemId == 335) {
			    if (player.skillLvl[7] < 15) {
				player.frames.sendMessage(player, "You need level 15 Cooking to cook Trout.");
			    } else {
				player.cookXP = 140;
				player.cookID = 335;
				player.cookGet = 333;
				player.Cooking = true;
				player.cookName = "Trout";
				player.frames.removeChatboxInterface(player);
				player.frames.showChatboxInterface(player, 307);
				player.frames.addInterfaceItem(player, 307, 2, 175, player.cookID);
				player.frames.setString(player, ""+ player.cookName +"", 307, 4);
			    }
			}
			if (itemId == 349) {
			    if (player.skillLvl[7] < 20) {
				player.frames.sendMessage(player, "You need level 20 Cooking to cook Pike.");
			    } else {
				player.cookXP = 175;
				player.cookID = 349;
				player.cookGet = 351;
				player.Cooking = true;
				player.cookName = "Pike";
				player.frames.removeChatboxInterface(player);
				player.frames.showChatboxInterface(player, 307);
				player.frames.addInterfaceItem(player, 307, 2, 175, player.cookID);
				player.frames.setString(player, ""+ player.cookName +"", 307, 4);
			    }
			}
			if (itemId == 331) {
			    if (player.skillLvl[7] < 25) {
				player.frames.sendMessage(player, "You need level 25 Cooking to cook Salmon.");
			    } else {
				player.cookXP = 210;
				player.cookID = 331;
				player.cookGet = 329;
				player.Cooking = true;
				player.cookName = "Salmon";
				player.frames.removeChatboxInterface(player);
				player.frames.showChatboxInterface(player, 307);
				player.frames.addInterfaceItem(player, 307, 2, 175, player.cookID);
				player.frames.setString(player, ""+ player.cookName +"", 307, 4);
			    }
			}
			if (itemId == 359) {
			    if (player.skillLvl[7] < 30) {
				player.frames.sendMessage(player, "You need level 30 Cooking to cook Tuna.");
			    } else {
				player.cookXP = 240;
				player.cookID = 359;
				player.cookGet = 361;
				player.Cooking = true;
				player.cookName = "Tuna";
				player.frames.removeChatboxInterface(player);
				player.frames.showChatboxInterface(player, 307);
				player.frames.addInterfaceItem(player, 307, 2, 175, player.cookID);
				player.frames.setString(player, ""+ player.cookName +"", 307, 4);
			    }
			}
			if (itemId == 377) {
			    if (player.skillLvl[7] < 40) {
				player.frames.sendMessage(player, "You need level 40 Cooking to cook Lobster.");
			    } else {
				player.cookXP = 350;
				player.cookID = 377;
				player.cookGet = 379;
				player.Cooking = true;
				player.cookName = "Lobster";
				player.frames.removeChatboxInterface(player);
				player.frames.showChatboxInterface(player, 307);
				player.frames.addInterfaceItem(player, 307, 2, 175, player.cookID);
				player.frames.setString(player, ""+ player.cookName +"", 307, 4);
			    }
			}
			if (itemId == 363) {
			    if (player.skillLvl[7] < 43) {
				player.frames.sendMessage(player, "You need level 43 Cooking to cook Bass.");
			    } else {
				player.cookXP = 385;
				player.cookID = 363;
				player.cookGet = 365;
				player.Cooking = true;
				player.cookName = "Bass";
				player.frames.removeChatboxInterface(player);
				player.frames.showChatboxInterface(player, 307);
				player.frames.addInterfaceItem(player, 307, 2, 175, player.cookID);
				player.frames.setString(player, ""+ player.cookName +"", 307, 4);
			    }
			}
			if (itemId == 371) {
			    if (player.skillLvl[7] < 45) {
				player.frames.sendMessage(player, "You need level 45 Cooking to cook Swordfish.");
			    } else {
				player.cookXP = 425;
				player.cookID = 371;
				player.cookGet = 373;
				player.Cooking = true;
				player.cookName = "Swordfish";
				player.frames.removeChatboxInterface(player);
				player.frames.showChatboxInterface(player, 307);
				player.frames.addInterfaceItem(player, 307, 2, 175, player.cookID);
				player.frames.setString(player, ""+ player.cookName +"", 307, 4);
			    }
			}
			if (itemId == 7944) {
			    if (player.skillLvl[7] < 62) {
				player.frames.sendMessage(player, "You need level 62 Cooking to cook Monkfish.");
			    } else {
				player.cookXP = 655;
				player.cookID = 7944;
				player.cookGet = 7946;
				player.Cooking = true;
				player.cookName = "Monkfish";
				player.frames.removeChatboxInterface(player);
				player.frames.showChatboxInterface(player, 307);
				player.frames.addInterfaceItem(player, 307, 2, 175, player.cookID);
				player.frames.setString(player, ""+ player.cookName +"", 307, 4);
			    }
			}
			if (itemId == 383) {
			    if (player.skillLvl[7] < 80) {
				player.frames.sendMessage(player, "You need level 80 Cooking to cook Shark.");
			    } else {
				player.cookXP = 850;
				player.cookID = 383;
				player.cookGet = 385;
				player.Cooking = true;
				player.cookName = "Shark";
				player.frames.removeChatboxInterface(player);
				player.frames.showChatboxInterface(player, 307);
				player.frames.addInterfaceItem(player, 307, 2, 175, player.cookID);
				player.frames.setString(player, ""+ player.cookName +"", 307, 4);
			    }
			}
			if (itemId == 389) {
			    if (player.skillLvl[7] < 91) {
				player.frames.sendMessage(player, "You need level 91 Cooking to cook Manta ray.");
			    } else {
				player.cookXP = 1100;
				player.cookID = 389;
				player.cookGet = 391;
				player.Cooking = true;
				player.cookName = "Manta ray";
				player.frames.removeChatboxInterface(player);
				player.frames.showChatboxInterface(player, 307);
				player.frames.addInterfaceItem(player, 307, 2, 175, player.cookID);
				player.frames.setString(player, ""+ player.cookName +"", 307, 4);
			    }
			}
		    }
	}

}